<?php
namespace MLM\Model;

use MLM\Model\Generic\Object\Map;
use MLM\Model\Generic\Object\Mapper;
use Zend\Mail\Message;
use Zend\Mime\Message as MimeMessage;
use Zend\Mime\Part as MimePart;
use Zend\Mail\Transport\Sendmail as SendmailTransport;

use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mail\Transport\SmtpOptions;

class Functions extends Mapper {
    

    function setCurrency($code, $rp)
    {
            $rp = ceil($rp);
            
            if ($rp<0)
            {
                    $rp=substr($rp,1,strlen($rp));
                    $min="-";
            }else $min="";

            $rupiah="";
            $p=strlen($rp);
            while ($p > 3)
                            {
                                    $rupiah="," . substr($rp,-3) . $rupiah;
                                    $l = strlen($rp) - 3;
                                    $rp = substr($rp,0,$l);
                                    $p= strlen($rp);
                            }
            $rupiah = $code." " . $min . $rp . $rupiah . ".00";
            return $rupiah;
    }

    function gatMonthName($month){
        if ($month != ""){
            $arrMonth = array("01" => "January",
                                "02" => "February",
                                "03" => "March",
                                "04" => "April",
                                "05" => "May",
                                "06" => "June",
                                "07" => "July",
                                "08" => "August",
                                "09" => "September",
                                "10" => "October",
                                "11" => "November",
                                "12" => "December");

           return $arrMonth[$month];
        }
    }

    function getMonthNum($month){
        if ($month != ""){
            $arrMonth = array("January"  =>   "01" ,
                                "February" =>   "02" ,
                                "March"    =>   "03" ,
                                "April"    =>   "04" ,
                                "May"      =>   "05" ,
                                "June"     =>   "06" ,
                                "July"     =>   "07" ,
                                "August"   =>   "08" ,
                                "September"=>   "09" ,
                                "October"  =>   "10" ,
                                "November" =>   "11" ,
                                "December"  =>   "12");

           return $arrMonth[$month];
        }
    }


    function countryList(){

            $arrCountry = array(
                                array('code' => 'AF', 'name' => 'Afghanistan'),
                                array('code' => 'AX', 'name' => 'Aland Islands'),
                                array('code' => 'AL', 'name' => 'Albania'),
                                array('code' => 'DZ', 'name' => 'Algeria'),
                                array('code' => 'AS', 'name' => 'American Samoa'),
                                array('code' => 'AD', 'name' => 'Andorra'),
                                array('code' => 'AO', 'name' => 'Angola'),
                                array('code' => 'AI', 'name' => 'Anguilla'),
                                array('code' => 'AQ', 'name' => 'Antarctica'),
                                array('code' => 'AG', 'name' => 'Antigua And Barbuda'),
                                array('code' => 'AR', 'name' => 'Argentina'),
                                array('code' => 'AM', 'name' => 'Armenia'),
                                array('code' => 'AW', 'name' => 'Aruba'),
                                array('code' => 'AU', 'name' => 'Australia'),
                                array('code' => 'AT', 'name' => 'Austria'),
                                array('code' => 'AZ', 'name' => 'Azerbaijan'),
                                array('code' => 'BS', 'name' => 'Bahamas'),
                                array('code' => 'BH', 'name' => 'Bahrain'),
                                array('code' => 'BD', 'name' => 'Bangladesh'),
                                array('code' => 'BB', 'name' => 'Barbados'),
                                array('code' => 'BY', 'name' => 'Belarus'),
                                array('code' => 'BE', 'name' => 'Belgium'),
                                array('code' => 'BZ', 'name' => 'Belize'),
                                array('code' => 'BJ', 'name' => 'Benin'),
                                array('code' => 'BM', 'name' => 'Bermuda'),
                                array('code' => 'BT', 'name' => 'Bhutan'),
                                array('code' => 'BO', 'name' => 'Bolivia'),
                                array('code' => 'BA', 'name' => 'Bosnia And Herzegovina'),
                                array('code' => 'BW', 'name' => 'Botswana'),
                                array('code' => 'BV', 'name' => 'Bouvet Island'),
                                array('code' => 'BR', 'name' => 'Brazil'),
                                array('code' => 'IO', 'name' => 'British Indian Ocean Territory'),
                                array('code' => 'BN', 'name' => 'Brunei Darussalam'),
                                array('code' => 'BG', 'name' => 'Bulgaria'),
                                array('code' => 'BF', 'name' => 'Burkina Faso'),
                                array('code' => 'BI', 'name' => 'Burundi'),
                                array('code' => 'KH', 'name' => 'Cambodia'),
                                array('code' => 'CM', 'name' => 'Cameroon'),
                                array('code' => 'CA', 'name' => 'Canada'),
                                array('code' => 'CV', 'name' => 'Cape Verde'),
                                array('code' => 'KY', 'name' => 'Cayman Islands'),
                                array('code' => 'CF', 'name' => 'Central African Republic'),
                                array('code' => 'TD', 'name' => 'Chad'),
                                array('code' => 'CL', 'name' => 'Chile'),
                                array('code' => 'CN', 'name' => 'China'),
                                array('code' => 'CX', 'name' => 'Christmas Island'),
                                array('code' => 'CC', 'name' => 'Cocos (Keeling) Islands'),
                                array('code' => 'CO', 'name' => 'Colombia'),
                                array('code' => 'KM', 'name' => 'Comoros'),
                                array('code' => 'CG', 'name' => 'Congo'),
                                array('code' => 'CD', 'name' => 'Congo), Democratic Republic'),
                                array('code' => 'CK', 'name' => 'Cook Islands'),
                                array('code' => 'CR', 'name' => 'Costa Rica'),
                                array('code' => 'CI', 'name' => 'Cote D\'Ivoire'),
                                array('code' => 'HR', 'name' => 'Croatia'),
                                array('code' => 'CU', 'name' => 'Cuba'),
                                array('code' => 'CY', 'name' => 'Cyprus'),
                                array('code' => 'CZ', 'name' => 'Czech Republic'),
                                array('code' => 'DK', 'name' => 'Denmark'),
                                array('code' => 'DJ', 'name' => 'Djibouti'),
                                array('code' => 'DM', 'name' => 'Dominica'),
                                array('code' => 'DO', 'name' => 'Dominican Republic'),
                                array('code' => 'EC', 'name' => 'Ecuador'),
                                array('code' => 'EG', 'name' => 'Egypt'),
                                array('code' => 'SV', 'name' => 'El Salvador'),
                                array('code' => 'GQ', 'name' => 'Equatorial Guinea'),
                                array('code' => 'ER', 'name' => 'Eritrea'),
                                array('code' => 'EE', 'name' => 'Estonia'),
                                array('code' => 'ET', 'name' => 'Ethiopia'),
                                array('code' => 'FK', 'name' => 'Falkland Islands (Malvinas)'),
                                array('code' => 'FO', 'name' => 'Faroe Islands'),
                                array('code' => 'FJ', 'name' => 'Fiji'),
                                array('code' => 'FI', 'name' => 'Finland'),
                                array('code' => 'FR', 'name' => 'France'),
                                array('code' => 'GF', 'name' => 'French Guiana'),
                                array('code' => 'PF', 'name' => 'French Polynesia'),
                                array('code' => 'TF', 'name' => 'French Southern Territories'),
                                array('code' => 'GA', 'name' => 'Gabon'),
                                array('code' => 'GM', 'name' => 'Gambia'),
                                array('code' => 'GE', 'name' => 'Georgia'),
                                array('code' => 'DE', 'name' => 'Germany'),
                                array('code' => 'GH', 'name' => 'Ghana'),
                                array('code' => 'GI', 'name' => 'Gibraltar'),
                                array('code' => 'GR', 'name' => 'Greece'),
                                array('code' => 'GL', 'name' => 'Greenland'),
                                array('code' => 'GD', 'name' => 'Grenada'),
                                array('code' => 'GP', 'name' => 'Guadeloupe'),
                                array('code' => 'GU', 'name' => 'Guam'),
                                array('code' => 'GT', 'name' => 'Guatemala'),
                                array('code' => 'GG', 'name' => 'Guernsey'),
                                array('code' => 'GN', 'name' => 'Guinea'),
                                array('code' => 'GW', 'name' => 'Guinea-Bissau'),
                                array('code' => 'GY', 'name' => 'Guyana'),
                                array('code' => 'HT', 'name' => 'Haiti'),
                                array('code' => 'HM', 'name' => 'Heard Island &amp; Mcdonald Islands'),
                                array('code' => 'VA', 'name' => 'Holy See (Vatican City State)'),
                                array('code' => 'HN', 'name' => 'Honduras'),
                                array('code' => 'HK', 'name' => 'Hongkong'),
                                array('code' => 'HU', 'name' => 'Hungary'),
                                array('code' => 'IS', 'name' => 'Iceland'),
                                array('code' => 'IN', 'name' => 'India'),
                                array('code' => 'ID', 'name' => 'Indonesia'),
                                array('code' => 'IR', 'name' => 'Iran, Islamic Republic Of'),
                                array('code' => 'IQ', 'name' => 'Iraq'),
                                array('code' => 'IE', 'name' => 'Ireland'),
                                array('code' => 'IM', 'name' => 'Isle Of Man'),
                                array('code' => 'IL', 'name' => 'Israel'),
                                array('code' => 'IT', 'name' => 'Italy'),
                                array('code' => 'JM', 'name' => 'Jamaica'),
                                array('code' => 'JP', 'name' => 'Japan'),
                                array('code' => 'JE', 'name' => 'Jersey'),
                                array('code' => 'JO', 'name' => 'Jordan'),
                                array('code' => 'KZ', 'name' => 'Kazakhstan'),
                                array('code' => 'KE', 'name' => 'Kenya'),
                                array('code' => 'KI', 'name' => 'Kiribati'),
                                array('code' => 'KR', 'name' => 'Korea'),
                                array('code' => 'KW', 'name' => 'Kuwait'),
                                array('code' => 'KG', 'name' => 'Kyrgyzstan'),
                                array('code' => 'LA', 'name' => 'Lao People\'s Democratic Republic'),
                                array('code' => 'LV', 'name' => 'Latvia'),
                                array('code' => 'LB', 'name' => 'Lebanon'),
                                array('code' => 'LS', 'name' => 'Lesotho'),
                                array('code' => 'LR', 'name' => 'Liberia'),
                                array('code' => 'LY', 'name' => 'Libyan Arab Jamahiriya'),
                                array('code' => 'LI', 'name' => 'Liechtenstein'),
                                array('code' => 'LT', 'name' => 'Lithuania'),
                                array('code' => 'LU', 'name' => 'Luxembourg'),
                                array('code' => 'MO', 'name' => 'Macao'),
                                array('code' => 'MK', 'name' => 'Macedonia'),
                                array('code' => 'MG', 'name' => 'Madagascar'),
                                array('code' => 'MW', 'name' => 'Malawi'),
                                array('code' => 'MY', 'name' => 'Malaysia'),
                                array('code' => 'MV', 'name' => 'Maldives'),
                                array('code' => 'ML', 'name' => 'Mali'),
                                array('code' => 'MT', 'name' => 'Malta'),
                                array('code' => 'MH', 'name' => 'Marshall Islands'),
                                array('code' => 'MQ', 'name' => 'Martinique'),
                                array('code' => 'MR', 'name' => 'Mauritania'),
                                array('code' => 'MU', 'name' => 'Mauritius'),
                                array('code' => 'YT', 'name' => 'Mayotte'),
                                array('code' => 'MX', 'name' => 'Mexico'),
                                array('code' => 'FM', 'name' => 'Micronesia), Federated States Of'),
                                array('code' => 'MD', 'name' => 'Moldova'),
                                array('code' => 'MC', 'name' => 'Monaco'),
                                array('code' => 'MN', 'name' => 'Mongolia'),
                                array('code' => 'ME', 'name' => 'Montenegro'),
                                array('code' => 'MS', 'name' => 'Montserrat'),
                                array('code' => 'MA', 'name' => 'Morocco'),
                                array('code' => 'MZ', 'name' => 'Mozambique'),
                                array('code' => 'MM', 'name' => 'Myanmar'),
                                array('code' => 'NA', 'name' => 'Namibia'),
                                array('code' => 'NR', 'name' => 'Nauru'),
                                array('code' => 'NP', 'name' => 'Nepal'),
                                array('code' => 'NL', 'name' => 'Netherlands'),
                                array('code' => 'AN', 'name' => 'Netherlands Antilles'),
                                array('code' => 'NC', 'name' => 'New Caledonia'),
                                array('code' => 'NZ', 'name' => 'New Zealand'),
                                array('code' => 'NI', 'name' => 'Nicaragua'),
                                array('code' => 'NE', 'name' => 'Niger'),
                                array('code' => 'NG', 'name' => 'Nigeria'),
                                array('code' => 'NU', 'name' => 'Niue'),
                                array('code' => 'NF', 'name' => 'Norfolk Island'),
                                array('code' => 'MP', 'name' => 'Northern Mariana Islands'),
                                array('code' => 'NO', 'name' => 'Norway'),
                                array('code' => 'OM', 'name' => 'Oman'),
                                array('code' => 'PK', 'name' => 'Pakistan'),
                                array('code' => 'PW', 'name' => 'Palau'),
                                array('code' => 'PS', 'name' => 'Palestinian Territory), Occupied'),
                                array('code' => 'PA', 'name' => 'Panama'),
                                array('code' => 'PG', 'name' => 'Papua New Guinea'),
                                array('code' => 'PY', 'name' => 'Paraguay'),
                                array('code' => 'PE', 'name' => 'Peru'),
                                array('code' => 'PH', 'name' => 'Philippines'),
                                array('code' => 'PN', 'name' => 'Pitcairn'),
                                array('code' => 'PL', 'name' => 'Poland'),
                                array('code' => 'PT', 'name' => 'Portugal'),
                                array('code' => 'PR', 'name' => 'Puerto Rico'),
                                array('code' => 'QA', 'name' => 'Qatar'),
                                array('code' => 'RE', 'name' => 'Reunion'),
                                array('code' => 'RO', 'name' => 'Romania'),
                                array('code' => 'RU', 'name' => 'Russian Federation'),
                                array('code' => 'RW', 'name' => 'Rwanda'),
                                array('code' => 'BL', 'name' => 'Saint Barthelemy'),
                                array('code' => 'SH', 'name' => 'Saint Helena'),
                                array('code' => 'KN', 'name' => 'Saint Kitts And Nevis'),
                                array('code' => 'LC', 'name' => 'Saint Lucia'),
                                array('code' => 'MF', 'name' => 'Saint Martin'),
                                array('code' => 'PM', 'name' => 'Saint Pierre And Miquelon'),
                                array('code' => 'VC', 'name' => 'Saint Vincent And Grenadines'),
                                array('code' => 'WS', 'name' => 'Samoa'),
                                array('code' => 'SM', 'name' => 'San Marino'),
                                array('code' => 'ST', 'name' => 'Sao Tome And Principe'),
                                array('code' => 'SA', 'name' => 'Saudi Arabia'),
                                array('code' => 'SN', 'name' => 'Senegal'),
                                array('code' => 'RS', 'name' => 'Serbia'),
                                array('code' => 'SC', 'name' => 'Seychelles'),
                                array('code' => 'SL', 'name' => 'Sierra Leone'),
                                array('code' => 'SG', 'name' => 'Singapore'),
                                array('code' => 'SK', 'name' => 'Slovakia'),
                                array('code' => 'SI', 'name' => 'Slovenia'),
                                array('code' => 'SB', 'name' => 'Solomon Islands'),
                                array('code' => 'SO', 'name' => 'Somalia'),
                                array('code' => 'ZA', 'name' => 'South Africa'),
                                array('code' => 'GS', 'name' => 'South Georgia And Sandwich Isl.'),
                                array('code' => 'ES', 'name' => 'Spain'),
                                array('code' => 'LK', 'name' => 'Sri Lanka'),
                                array('code' => 'SD', 'name' => 'Sudan'),
                                array('code' => 'SR', 'name' => 'Suriname'),
                                array('code' => 'SJ', 'name' => 'Svalbard And Jan Mayen'),
                                array('code' => 'SZ', 'name' => 'Swaziland'),
                                array('code' => 'SE', 'name' => 'Sweden'),
                                array('code' => 'CH', 'name' => 'Switzerland'),
                                array('code' => 'SY', 'name' => 'Syrian Arab Republic'),
                                array('code' => 'TW', 'name' => 'Taiwan'),
                                array('code' => 'TJ', 'name' => 'Tajikistan'),
                                array('code' => 'TZ', 'name' => 'Tanzania'),
                                array('code' => 'TH', 'name' => 'Thailand'),
                                array('code' => 'TL', 'name' => 'Timor-Leste'),
                                array('code' => 'TG', 'name' => 'Togo'),
                                array('code' => 'TK', 'name' => 'Tokelau'),
                                array('code' => 'TO', 'name' => 'Tonga'),
                                array('code' => 'TT', 'name' => 'Trinidad And Tobago'),
                                array('code' => 'TN', 'name' => 'Tunisia'),
                                array('code' => 'TR', 'name' => 'Turkey'),
                                array('code' => 'TM', 'name' => 'Turkmenistan'),
                                array('code' => 'TC', 'name' => 'Turks And Caicos Islands'),
                                array('code' => 'TV', 'name' => 'Tuvalu'),
                                array('code' => 'UG', 'name' => 'Uganda'),
                                array('code' => 'UA', 'name' => 'Ukraine'),
                                array('code' => 'AE', 'name' => 'United Arab Emirates'),
                                array('code' => 'GB', 'name' => 'United Kingdom'),
                                array('code' => 'US', 'name' => 'United States'),
                                array('code' => 'UM', 'name' => 'United States Outlying Islands'),
                                array('code' => 'UY', 'name' => 'Uruguay'),
                                array('code' => 'UZ', 'name' => 'Uzbekistan'),
                                array('code' => 'VU', 'name' => 'Vanuatu'),
                                array('code' => 'VE', 'name' => 'Venezuela'),
                                array('code' => 'VN', 'name' => 'Viet Nam'),
                                array('code' => 'VG', 'name' => 'Virgin Islands), British'),
                                array('code' => 'VI', 'name' => 'Virgin Islands), U.S.'),
                                array('code' => 'WF', 'name' => 'Wallis And Futuna'),
                                array('code' => 'EH', 'name' => 'Western Sahara'),
                                array('code' => 'YE', 'name' => 'Yemen'),
                                array('code' => 'ZM', 'name' => 'Zambia'),
                                array('code' => 'ZW', 'name' => 'Zimbabwe')
                        );

             return $arrCountry;

    }


    function getCountry($country){
        if ($country != ""){
            $arrCountry = array(
                                  'AF' => 'Afghanistan',
                                  'AX' => 'Aland Islands',
                                  'AL' => 'Albania',
                                  'DZ' => 'Algeria',
                                  'AS' => 'American Samoa',
                                  'AD' => 'Andorra',
                                  'AO' => 'Angola',
                                  'AI' => 'Anguilla',
                                  'AQ' => 'Antarctica',
                                  'AG' => 'Antigua And Barbuda',
                                  'AR' => 'Argentina',
                                  'AM' => 'Armenia',
                                  'AW' => 'Aruba',
                                  'AU' => 'Australia',
                                  'AT' => 'Austria',
                                  'AZ' => 'Azerbaijan',
                                  'BS' => 'Bahamas',
                                  'BH' => 'Bahrain',
                                  'BD' => 'Bangladesh',
                                  'BB' => 'Barbados',
                                  'BY' => 'Belarus',
                                  'BE' => 'Belgium',
                                  'BZ' => 'Belize',
                                  'BJ' => 'Benin',
                                  'BM' => 'Bermuda',
                                  'BT' => 'Bhutan',
                                  'BO' => 'Bolivia',
                                  'BA' => 'Bosnia And Herzegovina',
                                  'BW' => 'Botswana',
                                  'BV' => 'Bouvet Island',
                                  'BR' => 'Brazil',
                                  'IO' => 'British Indian Ocean Territory',
                                  'BN' => 'Brunei Darussalam',
                                  'BG' => 'Bulgaria',
                                  'BF' => 'Burkina Faso',
                                  'BI' => 'Burundi',
                                  'KH' => 'Cambodia',
                                  'CM' => 'Cameroon',
                                  'CA' => 'Canada',
                                  'CV' => 'Cape Verde',
                                  'KY' => 'Cayman Islands',
                                  'CF' => 'Central African Republic',
                                  'TD' => 'Chad',
                                  'CL' => 'Chile',
                                  'CN' => 'China',
                                  'CX' => 'Christmas Island',
                                  'CC' => 'Cocos (Keeling) Islands',
                                  'CO' => 'Colombia',
                                  'KM' => 'Comoros',
                                  'CG' => 'Congo',
                                  'CD' => 'Congo, Democratic Republic',
                                  'CK' => 'Cook Islands',
                                  'CR' => 'Costa Rica',
                                  'CI' => 'Cote D\'Ivoire',
                                  'HR' => 'Croatia',
                                  'CU' => 'Cuba',
                                  'CY' => 'Cyprus',
                                  'CZ' => 'Czech Republic',
                                  'DK' => 'Denmark',
                                  'DJ' => 'Djibouti',
                                  'DM' => 'Dominica',
                                  'DO' => 'Dominican Republic',
                                  'EC' => 'Ecuador',
                                  'EG' => 'Egypt',
                                  'SV' => 'El Salvador',
                                  'GQ' => 'Equatorial Guinea',
                                  'ER' => 'Eritrea',
                                  'EE' => 'Estonia',
                                  'ET' => 'Ethiopia',
                                  'FK' => 'Falkland Islands (Malvinas)',
                                  'FO' => 'Faroe Islands',
                                  'FJ' => 'Fiji',
                                  'FI' => 'Finland',
                                  'FR' => 'France',
                                  'GF' => 'French Guiana',
                                  'PF' => 'French Polynesia',
                                  'TF' => 'French Southern Territories',
                                  'GA' => 'Gabon',
                                  'GM' => 'Gambia',
                                  'GE' => 'Georgia',
                                  'DE' => 'Germany',
                                  'GH' => 'Ghana',
                                  'GI' => 'Gibraltar',
                                  'GR' => 'Greece',
                                  'GL' => 'Greenland',
                                  'GD' => 'Grenada',
                                  'GP' => 'Guadeloupe',
                                  'GU' => 'Guam',
                                  'GT' => 'Guatemala',
                                  'GG' => 'Guernsey',
                                  'GN' => 'Guinea',
                                  'GW' => 'Guinea-Bissau',
                                  'GY' => 'Guyana',
                                  'HT' => 'Haiti',
                                  'HM' => 'Heard Island &amp; Mcdonald Islands',
                                  'VA' => 'Holy See (Vatican City State)',
                                  'HN' => 'Honduras',
                                  'HK' => 'Hongkong',
                                  'HU' => 'Hungary',
                                  'IS' => 'Iceland',
                                  'IN' => 'India',
                                  'ID' => 'Indonesia',
                                  'IR' => 'Iran, Islamic Republic Of',
                                  'IQ' => 'Iraq',
                                  'IE' => 'Ireland',
                                  'IM' => 'Isle Of Man',
                                  'IL' => 'Israel',
                                  'IT' => 'Italy',
                                  'JM' => 'Jamaica',
                                  'JP' => 'Japan',
                                  'JE' => 'Jersey',
                                  'JO' => 'Jordan',
                                  'KZ' => 'Kazakhstan',
                                  'KE' => 'Kenya',
                                  'KI' => 'Kiribati',
                                  'KR' => 'Korea',
                                  'KW' => 'Kuwait',
                                  'KG' => 'Kyrgyzstan',
                                  'LA' => 'Lao People\'s Democratic Republic',
                                  'LV' => 'Latvia',
                                  'LB' => 'Lebanon',
                                  'LS' => 'Lesotho',
                                  'LR' => 'Liberia',
                                  'LY' => 'Libyan Arab Jamahiriya',
                                  'LI' => 'Liechtenstein',
                                  'LT' => 'Lithuania',
                                  'LU' => 'Luxembourg',
                                  'MO' => 'Macao',
                                  'MK' => 'Macedonia',
                                  'MG' => 'Madagascar',
                                  'MW' => 'Malawi',
                                  'MY' => 'Malaysia',
                                  'MV' => 'Maldives',
                                  'ML' => 'Mali',
                                  'MT' => 'Malta',
                                  'MH' => 'Marshall Islands',
                                  'MQ' => 'Martinique',
                                  'MR' => 'Mauritania',
                                  'MU' => 'Mauritius',
                                  'YT' => 'Mayotte',
                                  'MX' => 'Mexico',
                                  'FM' => 'Micronesia, Federated States Of',
                                  'MD' => 'Moldova',
                                  'MC' => 'Monaco',
                                  'MN' => 'Mongolia',
                                  'ME' => 'Montenegro',
                                  'MS' => 'Montserrat',
                                  'MA' => 'Morocco',
                                  'MZ' => 'Mozambique',
                                  'MM' => 'Myanmar',
                                  'NA' => 'Namibia',
                                  'NR' => 'Nauru',
                                  'NP' => 'Nepal',
                                  'NL' => 'Netherlands',
                                  'AN' => 'Netherlands Antilles',
                                  'NC' => 'New Caledonia',
                                  'NZ' => 'New Zealand',
                                  'NI' => 'Nicaragua',
                                  'NE' => 'Niger',
                                  'NG' => 'Nigeria',
                                  'NU' => 'Niue',
                                  'NF' => 'Norfolk Island',
                                  'MP' => 'Northern Mariana Islands',
                                  'NO' => 'Norway',
                                  'OM' => 'Oman',
                                  'PK' => 'Pakistan',
                                  'PW' => 'Palau',
                                  'PS' => 'Palestinian Territory, Occupied',
                                  'PA' => 'Panama',
                                  'PG' => 'Papua New Guinea',
                                  'PY' => 'Paraguay',
                                  'PE' => 'Peru',
                                  'PH' => 'Philippines',
                                  'PN' => 'Pitcairn',
                                  'PL' => 'Poland',
                                  'PT' => 'Portugal',
                                  'PR' => 'Puerto Rico',
                                  'QA' => 'Qatar',
                                  'RE' => 'Reunion',
                                  'RO' => 'Romania',
                                  'RU' => 'Russian Federation',
                                  'RW' => 'Rwanda',
                                  'BL' => 'Saint Barthelemy',
                                  'SH' => 'Saint Helena',
                                  'KN' => 'Saint Kitts And Nevis',
                                  'LC' => 'Saint Lucia',
                                  'MF' => 'Saint Martin',
                                  'PM' => 'Saint Pierre And Miquelon',
                                  'VC' => 'Saint Vincent And Grenadines',
                                  'WS' => 'Samoa',
                                  'SM' => 'San Marino',
                                  'ST' => 'Sao Tome And Principe',
                                  'SA' => 'Saudi Arabia',
                                  'SN' => 'Senegal',
                                  'RS' => 'Serbia',
                                  'SC' => 'Seychelles',
                                  'SL' => 'Sierra Leone',
                                  'SG' => 'Singapore',
                                  'SK' => 'Slovakia',
                                  'SI' => 'Slovenia',
                                  'SB' => 'Solomon Islands',
                                  'SO' => 'Somalia',
                                  'ZA' => 'South Africa',
                                  'GS' => 'South Georgia And Sandwich Isl.',
                                  'ES' => 'Spain',
                                  'LK' => 'Sri Lanka',
                                  'SD' => 'Sudan',
                                  'SR' => 'Suriname',
                                  'SJ' => 'Svalbard And Jan Mayen',
                                  'SZ' => 'Swaziland',
                                  'SE' => 'Sweden',
                                  'CH' => 'Switzerland',
                                  'SY' => 'Syrian Arab Republic',
                                  'TW' => 'Taiwan',
                                  'TJ' => 'Tajikistan',
                                  'TZ' => 'Tanzania',
                                  'TH' => 'Thailand',
                                  'TL' => 'Timor-Leste',
                                  'TG' => 'Togo',
                                  'TK' => 'Tokelau',
                                  'TO' => 'Tonga',
                                  'TT' => 'Trinidad And Tobago',
                                  'TN' => 'Tunisia',
                                  'TR' => 'Turkey',
                                  'TM' => 'Turkmenistan',
                                  'TC' => 'Turks And Caicos Islands',
                                  'TV' => 'Tuvalu',
                                  'UG' => 'Uganda',
                                  'UA' => 'Ukraine',
                                  'AE' => 'United Arab Emirates',
                                  'GB' => 'United Kingdom',
                                  'US' => 'United States',
                                  'UM' => 'United States Outlying Islands',
                                  'UY' => 'Uruguay',
                                  'UZ' => 'Uzbekistan',
                                  'VU' => 'Vanuatu',
                                  'VE' => 'Venezuela',
                                  'VN' => 'Viet Nam',
                                  'VG' => 'Virgin Islands, British',
                                  'VI' => 'Virgin Islands, U.S.',
                                  'WF' => 'Wallis And Futuna',
                                  'EH' => 'Western Sahara',
                                  'YE' => 'Yemen',
                                  'ZM' => 'Zambia',
                                  'ZW' => 'Zimbabwe'
                        );

             return $arrCountry[$country];
        }
    }


    function currencyList(){

            $arrCurrency = array(
                                array('code' => 'USD', 'name' => 'USD American Dollar')
                                );

            return $arrCurrency;
    }

    function getCurrencyName($currency){
        if ($currency != ""){
            $arrCurrency = array(
                                  'USD' => 'USD American Dollar',
                                  'IDR' => 'IDR Indonesian Rupiah'
                                  );
        }

        return $arrCurrency[$currency];
    }

    function phoneCodeList(){

            $arrPhoneCode = array('+62', 
                                    '+1',
                                    '+7',
                                    '+20',
                                    '+27',
                                    '+30',
                                    '+31',
                                    '+32',
                                    '+33',
                                    '+34',
                                    '+36',
                                    '+39',
                                    '+40',
                                    '+41',
                                    '+43',
                                    '+44',
                                    '+45',
                                    '+46',
                                    '+47',
                                    '+48',
                                    '+49',
                                    '+51',
                                    '+52',
                                    '+53',
                                    '+54',
                                    '+55',
                                    '+56',
                                    '+57',
                                    '+58',
                                    '+60',
                                    '+61',
                                    '+62',
                                    '+63',
                                    '+64',
                                    '+65',
                                    '+66',
                                    '+81',
                                    '+82',
                                    '+84',
                                    '+86',
                                    '+90',
                                    '+91',
                                    '+92',
                                    '+93',
                                    '+94',
                                    '+95',
                                    '+98',
                                    '+212',
                                    '+213',
                                    '+216',
                                    '+218',
                                    '+220',
                                    '+221',
                                    '+222',
                                    '+223',
                                    '+224',
                                    '+225');

            return $arrPhoneCode;

    }

    function getPhoneCodeArea($phoneNo){
        $arrCode = $this->phoneCodeList();

        $areaCode = "";

        $plusPhone = "+".$phoneNo;
        for ($x=0;$x<count($arrCode);$x++){
            $pos = strpos($plusPhone, $arrCode[$x]);
            if ($pos !== false) {
                $areaCode = $arrCode[$x];
                $areaCode = str_replace("+", "", $areaCode);
                break;
            }
        }

        return $areaCode;
    }


    public function paymentNameList(){
        
            $payments = array(
                                  array('code' => '1', 'name' => 'E-Wallet'),
                                  array('code' => '2', 'name' => 'Perfect Money (Account: U7710006)'),
                                  array('code' => '3', 'name' => 'Ego Pay'),
                                  array('code' => '4', 'name' => 'PayPal')
                                  );
        

        return $payments;
    }


    public function getPaymentName($payment){
        if ($payment != ""){
            $payments = array(
                                  '1' => 'E-Wallet',
                                  '2' => 'Perfect Money (Account: U7710006)',
                                  '3' => 'Ego Pay',
                                  '4' => 'PayPal',
                                  );
        }

        return $payments[$payment];
    }

    function getRunningText(){
        
        $select = $this->_db->select();
        $select->from('running_text');
        $select->where( "DATE_FORMAT(start_dat, '%Y%m%d') <= DATE_FORMAT(now(), '%Y%m%d') and DATE_FORMAT(end_dat, '%Y%m%d') >= DATE_FORMAT(now(), '%Y%m%d')");
        $select->order( 'start_dat' );
        $select->order( 'end_dat' );


        $stmt = $select->query();
        $result = $stmt->fetchAll();

        $num = count($result);

        $text = "";

        if ($num > 0){
            for($k = 0;$k<$num;$k++) {

                $text .= $result[$k]['text'].". ";

            }
        }

        return $text;

    }


    public function sendMail($mailTo, $mailMsg, $mailSubject = ""){

        $subject = ($mailSubject == "") ? "Selamat Datang di Qowwam" : $mailSubject;

        $message = new Message();
        $message->addFrom("fxtradepoint.co.uk@gmail.com")
                ->addTo($mailTo)
                ->setSubject($subject);
        

        $html = new MimePart($mailMsg);
        $html->type = "text/html";

        $body = new MimeMessage();
        $body->setParts(array($html));

        $message->setBody($body);

        //$transport = new SendmailTransport();

        $transport = new SmtpTransport();
        $options   = new SmtpOptions(array(
            'name'              => 'fx-tradepoint.co.uk',
            'host'              => 'smtp.gmail.com',
            'port'              => '587',
            'connection_class'  => 'login',
            'connection_config' => array(
                'ssl'               => 'tls',
                'username' => 'fxtradepoint.co.uk@gmail.com',
                'password' => 'fxtrade123'
            ),
        ));

        $transport->setOptions($options);
        
        $transport->send($message);
    }

}

?>
